#include "CLParametrization.hpp"

CLParametrization::CLParametrization( const std::vector<Spline::Point>& points ) :
	Parametrization( points.size() )
{	
	_parametrization[0] = 0;

	uint k = 1;
	std::vector<Spline::Point>::const_iterator point, prev;
	for( point = points.begin()+1 ; point != points.end() ; point++ )
	{
		prev = point-1;
		
		// variación del parámetro proporcional a la distancia
		double dx = (point->x-prev->x);
		double dy = (point->y-prev->y);
		double distance = std::sqrt(dx*dx+dy*dy);
		_parametrization[k] = _parametrization[k-1] + distance;
		k++;
	}

	// divide cada t_j por la longitud total
	forn( j, points.size()-1 )
		_parametrization[j] /= _parametrization[points.size()-1];

}

